var dvpublic = dvpublic || {};
dvpublic.posts = {
	refresh: function (event){
		var data = event.data;
		
		$("#spinner").show();
		$.ajax({url: data.url,
				type: "POST",
				data: {searchingKeyword: data.searchingKeyword}
					})
		.fail(function(){
			//$("#spinner").hide();
			})
		.done(function(posts){
			var $tblResult = $("<table id='tblResult' class='table-border'></table>");
			var $tbBody = $("<tbody></tbody>");				
			for(var i = 0; i < posts.length; i++) {
				var item = posts[i];
				var $newRow = $("<tr></tr>");
				$newRow.append("<td><div><img src='" + item.profileImageUrl + "'/></div></td>");
				$newRow.append("<td><div>" + item.name + "</div></td>");					
				$newRow.append("<td><div>" + item.text + "</div></td>");
				$tbBody.append($newRow);
			}
			$tblResult.append($tbBody);
			setTimeout(function() {
				$tblResult.replaceAll("#tblResult");
				$("#spinner").hide();					
				}, 500);			
			});		
	}	
};